Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RETURN_TIME_AS_PERIOD for relative times with hours/minutes/seconds #1044

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

miseran
Copy link

@miseran miseran commented Mar 12, 2022

Currently, a relative time with granularity less than a day will still result in a period of day, even when RETURN_TIME_AS_PERIOD is set:

In [1]: parser = dateparser.date.DateDataParser(settings={'RETURN_TIME_AS_PERIOD': True})

In [2]: parser.get_date_data('in 2 hours')
Out[2]: DateData(date_obj=datetime.datetime(2022, 3, 12, 19, 47, 25, 221085), period='day', locale='en')

This PR changes that behaviour, so that a period of time is is returned in this case.

The PR doesn't change the behaviour when RETURN_TIME_AS_PERIOD is false. This means that in 2 months and 2 hours results in period month, even though the actual granularity is much finer. I find this counter-intuitive, however there are tests for this, so I kept that behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant